package com.shanghai.market.plshnaghai.utils;

import android.graphics.Bitmap;
import android.widget.ImageView;

import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer;
import com.nostra13.universalimageloader.core.listener.ImageLoadingListener;
import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener;
import com.shanghai.market.plshnaghai.R;

public class ImageSyncUtils {

    public static void displayImage(String url, ImageView imageView) {
        final ImageLoadingListener animateFirstListener = new SimpleImageLoadingListener();
        final DisplayImageOptions options = new DisplayImageOptions.Builder()
                .showImageOnLoading(R.mipmap.icon_image_loading).showImageForEmptyUri(R.mipmap.icon_default)
                .showImageOnFail(R.mipmap.icon_default).cacheInMemory(true).cacheOnDisk(true)
                .considerExifParams(true).imageScaleType(ImageScaleType.EXACTLY)
                .bitmapConfig(Bitmap.Config.RGB_565)
                .displayer(new FadeInBitmapDisplayer(1000)).build();
        ImageLoader.getInstance().displayImage(url, imageView, options, animateFirstListener);
    }

//	public static void displayImage(String url, ImageView imageView, int defaultIndex) {
//		final ImageLoadingListener animateFirstListener = new SimpleImageLoadingListener();
//		final DisplayImageOptions options = new DisplayImageOptions.Builder()
//				.showImageOnLoading(defaultIndex).showImageForEmptyUri(defaultIndex)
//				.showImageOnFail(defaultIndex).cacheInMemory(true).cacheOnDisk(true)
//				.considerExifParams(true).imageScaleType(ImageScaleType.EXACTLY)
//				.bitmapConfig(Bitmap.Config.RGB_565)
//				.displayer(new FadeInBitmapDisplayer(1000)).build();
//		ImageLoader.getInstance().displayImage(url, imageView, options, animateFirstListener);
//	}
}
